home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 10 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. Path: lyra.csx.cam.ac.uk!nmm1
  2. From: nmm1@cus.cam.ac.uk (Nick Maclaren)
  3. Newsgroups: comp.std.c
  4. Subject: Re: Buffering??  What buffering??
  5. Date: 2 Jan 1996 10:43:33 GMT
  6. Organization: University of Cambridge, England
  7. Message-ID: <4cb28l$2gb@lyra.csx.cam.ac.uk>
  8. References: <4c9uk4$sa4@cygnus.com>
  9. NNTP-Posting-Host: ursa.cus.cam.ac.uk
  10.  
  11. In article <4c9uk4$sa4@cygnus.com>, rfg@monkeys.com (Ronald F. Guilmette) writes:
  12. |> I would like to know the exact semantics of the _IOFBF, _IOLBF, and
  13. |> _IONBF mode flags for the `setvbuf' function (subclause 7.9.5.6 of the
  14. |> ANSI/ISO C tandard).
  15. |> 
  16. |> Correct me if I'm wrong, but there doesn't seem to be any description
  17. |> whatsoever of the semantics of these flags in the C standard.  Given
  18. |> that, I rather wonder why these were standardized at all.  Certainly,
  19. |> to just say ``Here are some possible flags for this function.  We don't
  20. |> know what they do.'' doesn't help anybody.
  21.  
  22. See section 4.9.3 of the ANSI standard or the equivalent in the ISO one,
  23. but here is a rough description:
  24.  
  25. _IONBF causes each character to be read or written as it happens.
  26.  
  27. _IOLBF reads or writes data when the buffer is full or when a logical
  28. newline is encountered (and therein hangs a tale!)
  29.  
  30. _IOFBF does this only when the buffer is full.
  31.  
  32. fflush and fclose (but not necessarily rewind) cause the reading or
  33. writing to take place immediately.
  34.  
  35.  
  36. But remember that reading and writing refer only to C's interface
  37. with its environment, and not necessarily to the interaction of that
  38. environment with other environments or peripherals.  Until you have
  39. tried to do it (and probably failed), you cannot imagine how foul it
  40. is to write a message synchronously even within a single UNIX system.
  41. And as for networks :-(
  42.  
  43.  
  44. Nick Maclaren,
  45. University of Cambridge Computer Laboratory,
  46. New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
  47. Email:  nmm1@cam.ac.uk
  48. Tel.:  +44 1223 334761    Fax:  +44 1223 334679
  49.